<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" href="__ADMIN__/static/index/css/common.css" />
		<link rel="stylesheet" href="__ADMIN__/static/index/css/login.css" />
	</head>

	<body>
		<div class="middle">
			<a href="index.html"><img src="__ADMIN__/static/index/img/logo.jpg" alt="logo" /></a>
			<form class="login" method="post" action="#">
				<label for="name">登录名</label><input type="text" name="name" id="name" />
				<br />
				<label for="pwd">密码</label><input type="password" name="pwd" id="pwd" />
				<span class="square"></span>
				<br />
				<label>验证码</label><input type="text" name="code" id="code" />
				<img id="valia" style=" margin-top: 90px; cursor: pointer;" src="{:url('index/login/valia')}">
				<span class="change_img" id="change_img" style="cursor: pointer;">看不清，换一张</span>
				<br />
				<input class="sub" type="submit" id="subn" style="cursor: pointer;" >
				<span class="registic"><a href="{:url('index/reg/index')}">免费注册</a></span>
			</form>
		</div>
		<!--尾部-->
		{include file='public/_foot' /}
		<script type="text/javascript" src="__ADMIN__/static/index/js/login.js"></script>
		<script type="text/javascript" src="__ADMIN__/static/index/js/jquery.min.js"></script>
		<script type="text/javascript" src="__ADMIN__/static/admin/lib/layer/2.4/layer.js"></script>
		<script>
			window.onload=function(){
				//刷新验证码
				$('#valia').click(function(){
//					alert(111);return false;
					 changevali();
				})
				$('#change_img').click(function(){
					 changevali();
				})
				function changevali()
				{
					var img_src = $('#valia').attr('src');
					img_src  = img_src+'?'
					$('#valia').attr('src',img_src);
				}
				
				//Ajax请求
				$('#subn').click(function(){
//					alert(11);return false;
					var user_name = $('input[name=name]').val();
					var passwd = $('input[name=pwd]').val();
					var code = $('input[name=code]').val();
					if(
						user_name != '' &&
						passwd != '' &&
						code != '' 
					)
					{
//						alert(222);return false;
						$.ajax({
							type: 'POST',
							url: '{:url("index/login/index")}',
							data: {user_name:user_name,passwd:passwd,code:code},
	//						dataType: 'json',
							success: function(data) {
//								alert(data);return false;
								if(data==12001||data=='12001')
								{
									alert('登录成功');	
									window.location.href='{:url("index/index/index")}';
									return false;
								}
								else if(data==12004||data=='12004') 
								{
									alert('验证码错误');changevali();return false;
								}
								else if(data==12000||data=='12000') 
								{
									alert('登录失败，用户名或密码错误');return false;
								}
							},
							error: function(data) {
								console.log(data.msg);
							},
						});
					}
					else
					{
						alert('信息不完整，请重新输入！');
						return false;
					}
						return false;
				})
			
		    }
		</script>
	</body>

</html>